/******************************************************************************
 * * inter_alarm_calendar_interface.h - internal interface between alarm and calendar
 *
 * *(C) Copyright 2019 ASR International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#ifndef INTER_ALARM_CALENDAR_INTERFACE_H
#define INTER_ALARM_CALENDAR_INTERFACE_H

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    UINT16 Year;
    UINT8  Month;
    UINT8  Day;
    UINT8  Hour;
    UINT8  Min;
    UINT8  WDay;     // Sunday = 0
} If_Alarm_Calendar_Time_t;

typedef VOID (*AlarmCalendarCallback)(VOID);

typedef struct {
    If_Alarm_Calendar_Time_t AlarmTime;
    AlarmCalendarCallback    CallBack;
} If_Alarm_Calendar_Info_t;

/**
 * Alarm gets the alarm information of reminder from calendar
 * param (in) CurTime: UINT32, current time in seconds
 * param (in) AlarmTime: UINT32, alarm time in seconds from alarm module, invalid if 0xFFFFFFFF
 * param (out) Info: If_Alarm_Calendar_Info_t *Info, invalid if CallBack is NULL
 * return  INT8, 1 if calendar alarm is not set,
 *               0 if alarm and calendar alarm is set at the same time
 *               -1 if only calendar alarm is set
 */
extern INT8 Alarm_Calendar_Get_Alarm_Info_Req(UINT32 CurTime, UINT32 AlarmTime, If_Alarm_Calendar_Info_t *Info);

/**
 * calendar checks whether alarm is ringing in alarm module
 * param (in) VOID
 * return  BOOL
 */
extern BOOL Alarm_Calendar_Check_Alarm_Ringing(VOID);

/**
 * Calendar Informs alarm that the alarm information of reminder is changed
 * param (in) ZeroSec: BOOL, current time(min:sec) is XX:00 not XX:59
 * return  VOID
 */
extern VOID Alarm_Calendar_Alarm_Change_Ind(BOOL ZeroSec);

/**
 * Alarm informs calendar to check which alarm is ringing during power off
 * param (in) CurTime: hal_rtc_t *
 * param (in) SecondAlarm: UINT32, the nearest time of alarm to the current time
 * return  INT8: 1 if calendar alarm is not ringing,
 *               0 if calendar alarm is ringing at the same time
 *               -1 if calendar alarm is ringing
 */
extern INT8 Alarm_Calendar_Check_PowerOff_Alarm(hal_rtc_t *CurTime, UINT32 SecondAlarm);

/**
 * Alarm informs calendar to clear the rtc alarm
 * param (in) VOID
 * return  VOID
 */
extern VOID Alarm_Calendar_Clear_Alarm_Req(VOID);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*INTER_ALARM_CALENDAR_INTERFACE_H*/
